// import { createStore } from 'redux'
// import {persistStore, persistReducer} from 'redux-persist';
// import storage from 'redux-persist/lib/storage';
// // 源编辑数据
// let RuleData = {}

// const storageConfig = {
//   key: 'root', // 必须有的
//   storage: storage, // 缓存机制
//   blacklist: [RuleData,'age'] // reducer 里不持久化的数据,除此外均为持久化数据
// }

// let reducer = (state, action) => {
//   switch (action.type) {
//     case 'SAVE_RULE':
//       return RuleData = action.data
//       break;
//     default:
//       return state
//       break;
//   }
// }
// const myPersistReducer = persistReducer(storageConfig, reducer)
// const store = createStore(myPersistReducer)
// export const persistor = persistStore(store)
// // let store = createStore(reducer)

// export default store
import { createStore, action , persist} from 'easy-peasy'
let data = {
  RuleData: {
    title: "",
      author: "",
      version: 0,
      group: "",
      titleColor: "",
      url: "",
      col_type: "",
      class_name: "",
      class_url: "",
      area_name: "",
      area_url: "",
      year_name: "",
      year_url: "",
      sort_name: "",
      sort_url: "",
      find_rule: "",
      search_url: "",
      searchFind: "",
      detail_col_type: "",
      detail_find_rule: "",
      sdetail_col_type: "",
      sdetail_find_rule: "",
      ua: "",
      preRule: "",
  },
  addTodo: action((state, payload) => {
    console.log(state, payload)
    state.RuleData = payload;
  }),
}
const store = createStore(
  persist({
    RuleData: data
  },
  {
    allow: ['RuleData']
  })
)
export default store